import { PlayerDialog } from "./PlayerDialog";
import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { TaskNameLabel } from "./TaskNameLabel";
import { DialogInfo } from "../../../model/dialog/DialogInfo";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
//class TaskList
    
    export  class TaskList extends PlayerDialog
    {
        constructor()
        {
            super();
            this._bodySprite = new GBox();
            this._bodySprite.direction = GBoxDirection.VERTICAL;
            addChild(this._bodySprite);
            return;
        }

        /* internal  */onTaskClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=(arg1.target as TaskNameLabel).dialog;
            return;
        }

        public /* override */ updateData(arg1: Array<any>): void
        {
            var loc3=null;
            var loc4=null;
            var loc1=0;
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                loc3 = arg1[loc1] as DialogInfo;
                (loc4 = ObjectPool.getObject(TaskNameLabel)).updateData(loc3);
                this._bodySprite.addChild(loc4);
                loc4.addEventListener(flash.events.MouseEvent.CLICK, this.onTaskClick);
                ++loc1;
            }
            this._bodySprite.invalidate();
            super.updateData(arg1);
            return;
        }

        public /* override */ dispose(): void
        {
            var loc1=null;
            while (this._bodySprite.numChildren > 0) 
            {
                loc1 = this._bodySprite.getChildAt(0) as TaskNameLabel;
                loc1.removeEventListener(flash.events.MouseEvent.CLICK, this.onTaskClick);
                this._bodySprite.removeChild(loc1);
                ObjectPool.disposeObject(loc1, TaskNameLabel);
            }
            return;
        }

        public /* override */ get height(): number
        {
            return this._bodySprite.numChildren * 18;
        }

        /* internal */ /* var */_bodySprite: GBox;
    }
